import request from "@/utils/request";

//1.登陆
export function login({ username, password }) {
  return request.post("/admin/acl/index/login", {
    username,
    password
  });
}

/* 2.获取用户信息(根据token) */
export function getInfo() {
  return request.get("/admin/acl/index/info");
}

/* 3.退出登陆 */
export function logout() {
  return request.post(`/admin/acl/index/logout`);
}

// 登陆接口end

// 用户管理接口start

// 1.获取管理用户
export const reqUserList = userId =>
  request.get(`/admin/acl/user/get/${userId}`);

// 2.获取用户分页列表
export const reqUserListByPage = (page, limit, username) =>
  request.get(`/admin/acl/user/${page}/${limit}?username=${username}`);

// 3.新增管理用户
export const reqAddUser = userinfo =>
  request.post("/admin/acl/user/save", userinfo);

// 4.修改管理用户
export const reqUpdateUser = userinfo =>
  request.put("/admin/acl/user/update", userinfo);

// 5.根据id列表删除管理用户
export const reqDeleteAll = idArr =>
  request.delete("/admin/acl/user/batchRemove", {
    data: idArr
  });

// 6.删除管理用户
export const reqDeleteUser = id =>
  request.delete(`/admin/acl/user/remove/${id}`);

// 7.根据用户获取角色数据
export const reqUserRoleInfo = userId =>
  request.get(`/admin/acl/user/toAssign/${userId}`);

// 8.根据用户分配角色
export const reqSetRole = (userId, roleId) =>
  request.post(`/admin/acl/user/doAssign?userId=${userId}&roleId=${roleId}`);

// 用户管理接口end
